<?php 
session_start();
require_once("include/authen.php");
require_once("include/ui.php");

if ($_SESSION["permission"][$posScreen]["View"]=="0"){
	echo "<script>alert('".$no_permit."');</script>";
	echo "<meta http-equiv = refresh ; content = '0 ; url = mainscreen.php'>";
	exit();
}

echo headerPage("Credit Sale");
?>
<SCRIPT src="js/jquery.numeric.js"></script>
<SCRIPT src="js/js_credit.js"></SCRIPT> 
<script>
$(function() {
 
	$("#btnPrint").live('click',function(){
		$("#normal-screen").hide();
		$("#page-header").hide();
		$("#searchdata").hide();
		$(".toolbar-box").hide();
		$("#foolter_table").hide();
		$("#leftboder").hide();
		$("#rightboder").hide();
		window.print();
		
		$("#normal-screen").show();
		$("#page-header").show();
		$("#searchdata").show();
		$(".toolbar-box").show();
		$("#foolter_table").show();
		$("#leftboder").show();
		$("#rightboder").show();
	});	
});
</script>
<FORM name="Act" action="pos.php" id="Act" method="post"> 
<table width="1024" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="10" id='leftboder' style='border-left:2px solid #facb0c;'>&nbsp;</td>
    <td width="1004" valign="top">
        <div class="content-box">
            <div Class="toolbar-box">   
                <div class="t">
                    <div class="t">
                        <div class="t"></div>
                    </div>
                 </div>
                 <div class="m">
                    <div class="toolbar">
                        <table class="toolbar">
                        <tr>
							<td><a href="javascript:void('0');" id="btnBack">
								<span class="icon_back"></span>Back
								</a>
							</td>
							 <td>
								<a href="javascript:void('0');" title="Print" id="btnPrint">
								<span class="icon_Print"></span>Print
								</a>
							</td>
						</tr>
                        </table>
                    </div>
                      <div class="header" style="background-image: url(images/CreditSale.png);">
						Credit Sales
                      </div>
                <div class="clr"></div>
                 </div>
                 <div class="b">
                    <div class="b">
                        <div class="b"></div>
                    </div>
                 </div>
            </div>
               <div id="element-box">
                <div class="t">
					<div class="t">
						<div class="t"></div>
					</div>
				</div>
                <div class="m">
				  <table width="100%" id='searchdata'>
						<tr>
							<td width="15%" class="fontSearch" style="padding-left:20">
								Customer Code : 
							</td>
							<td width="85%" align=left >
								<input id="txtCustCode"  title="Filter by customer code "  type="text" size=40 name="txtCustCode" class="boxItem" />
							</td>
						</tr>
                        <tr>
                            <td width="15%" class="fontSearch" style="padding-left:20">
								Customer Name : 
                            </td>
							<td width="85%" align=left >
							<input id="txtCustName"  title="Filter by customer Name "  type="text"  	size=40 name="txtCustName" class="boxItem" />
							</td>
                         </tr>
					<?php  if ($_SESSION['branchtype'] =="3"){ ?>
						<tr>
							<td width="15%" class="fontSearch" style="padding-left:20">
								Branch Name : 
							</td>
							<td width="85%" align=left >
								<select id="cboBranch" style="width:15em;"></select>
							</td>
						</tr>
					<?php  }?>						 
                        <tr>
                            <td width="15%" class="fontSearch" style="padding-left:20">
								Status : 
                            </td>
							<td width="85%" align=left >
							 <select id="cboStatus" style="width:15em;">
								<option selected value="0">All</option>
								<option  value="1">Closed</option>
								<option  value="2">1 Month</option>
								<option  value="3">> 2 Months</option>
							 </select>
							</td>
                         </tr>
						 <tr><td/><td>
						 <a href="javascript:void('0');" id="btnSearch"><img src="./images/btn-search.gif" border=0/></a> </td></tr>
						 <tr><td colspan="2"></tr>
                    </table>
                    <table cellspacing="1" id="resultData" class=list>
                    <thead>
                       <tr>
								<th width="10%" >Code</th>
								<th style="display:none" >id</th>
								<th class="title" width="20%" >Branch</th>
								<th class="title" width="15%" >Name</th>
								<th  class="title" width="10%"  nowrap="nowrap">Buy Date</th>
								<th  class="title" width="10%"  nowrap="nowrap">Last Pay Date</th>
								<th  class="title" width="10%"  nowrap="nowrap">Total Amt</th>
								<th  class="title" width="10%"  nowrap="nowrap">Payment Amt</th>
								<th  class="title" width="10%"  nowrap="nowrap">Remain Amt</th>
								<th  class="title" width="5%"  nowrap="nowrap">..</th>
                       </tr>
                    </thead>
                   <tbody>
                   </tbody>
                   <tfoot>
                         <tr>
							<td colspan="9">
								<div class="boxfooter">
								<div id="paging_btn"> </div> 
								 <div class="totalpage">Total : <span id="rowCount">0</span>&nbsp;&nbsp;rows</div>
								 </div>
							</td>
                         </tr>
                     </tfoot>
                    </table>
                  <div class="clr"></div>
                </div>
                 <div class="b"><div class="b"><div class="b"></div></div></div>
                 <div class="clr"></div>
                </div> <!-- elementbox-->
        </div>
    </td>
    <td width="10" id='rightboder' style="border-right:2px solid #facb0c;">&nbsp;</td>
  </tr>
</table>
 </FORM>
 
 <div id="dialog-form" style='height:550px' >
<p class="validateTips">* fields are required.</p>
	<table cellpadding="0" cellspacing="0" border="0" width="100%" class="fieldset">
		<tr>
			<td width="25%"><label for="name">Customer Name :</label></td>
			<td width="75%" colspan='2' >
				<input type="text" name="name" readonly  id="name" class="text ui-widget-content ui-corner-all" />
			</td>
		</tr>
 
		<tr>
			<td><label for="name" >Total :</label></td>
			<td   colspan='2'>
				<input type="text" name="tAmount" readonly id="tAmount" class="text ui-widget-content ui-corner-all" style="font-weight:bold;color:#666;"/>
			</td>
		</tr>
	 
		<tr class='tr_payment'>
			<td><label for="name" >Remain :</label></td>
			<td colspan='2' >
				<input type="text" name="rAmount" readonly id="rAmount" class="text ui-widget-content ui-corner-all" style="font-weight:bold;color:red;"/>
			</td>
		</tr>
		<tr class='tr_paymentType'>
			<td><label for="name" >Payment Type : </label></td>
			<td colspan='2' align='left' style="font-size:12px;color:#666;padding-top:5px;" >
				<input type="radio" name="PayType" id='PayCash' checked value="1">Cash</input>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				<input type="radio" name="PayType" value="2">Credit Card</input>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				<input type="radio" name="PayType" value="3">Smart Purse</input>
			</td>
		</tr>	
		<tr id="tr_cardName" style="display:none">
			<td><label for="name" style="padding-left:10" ><span id="lblcardNo" >Card No. : *</span></label></td>
			<td colspan='2'  align=left valign="middle" >
				<input type="text" id="txtCardNo" name="txtCardNo" value="" class="text ui-widget-content ui-corner-all" />
			</td>
		</tr>		
		<tr class='tr_payment'>
			<td ><label for="name" >Payment : *</label></td>
			<td>
				<input type="text" name="pAmount"   id="pAmount" class="text ui-widget-content ui-corner-all" />
			</td>
			<td width="35%" align="left"><button id="btnAddPayment" style="font-size:12px">Add</button></td>
		</tr>
 		<tr>
			<td colspan="3" style="padding-top:5px;">
				<fieldset  class="ui-widget ui-widget-content">
					<legend style='padding:2px;margin:0 auto;'><label id="lblGroup">Payment History</label></legend>
					<table id="tbPayHistory" cellspacing="1" width="100%" cellpadding="2" border="0" 
						style="background-color:#f6f6f6;font-size:12px;border:1px solid #EAEAEA;">
						<thead>
							<tr style="background-color:#CCC;font-weight:bold;">
								<th width="5%" class='addBorderBottom'>No</th>
								<th style="display:none" class='addBorderBottom'>id</th>
								<th width="25%" class='addBorderBottom'>Date-Time</th>
								<th width="20%" class='addBorderBottom'>Type</th>
								<th width="20%" class='addBorderBottom'>CardNo</th>
								<th width="15%" class='addBorderBottom'>Amount</th>
								<th width="5%" class='addBorderBottom'>Delete</th>
							</tr>
						</thead>
						<tbody style="font-weight:normal;background-color:#fff">
						</tbody>
						<tfoot>
							<tr >
								<td colspan="3" align="left" style="font-size:11px;font-weight:bold;border-top:1px solid #ccc""> &nbsp;&nbsp;<span id='iCount' style="color:red">0</span> row(s)</td>
								<td colspan="3" align="right" style="font-size:11px;font-weight:bold;padding-right:5px;border-top:1px solid #ccc">Total Payment : &nbsp;<span id='dlgTotalPay' style="color:blue">0</span></td>
							</tr>
						</tfoot>
					</table>
				</fieldset>
			</td>
		</tr>
	</table>
</div>
<div id="dialog-confirm" title="Confirm delete?">
	<p style='font-size:13px'><span class="ui-icon ui-icon-alert" 
		style="float:left; margin:0 7px 20px 0;">
		</span>Are you sure to delete this payment?</p>
</div>
<?php 
echo footer();
?>